//
//  GenerateTXZViewController.m
//  WisdomCommunity
//
//  Created by Yahaong on 16/7/27.
//  Copyright © 2016年 zonten. All rights reserved.
//

#import "GenerateTXZViewController.h"
#import "YHMarcros.h"

@interface GenerateTXZViewController ()
@property (nonatomic ,strong)UIView *contentView;
@property (nonatomic ,strong)UIImageView *topImageView;
@property (nonatomic ,strong)UILabel *nameLabel;
@property (nonatomic ,strong)UIView *splitView;
@property (nonatomic ,strong)UILabel *tipLabel;
@property (nonatomic ,strong)UILabel *visitTimeLabel;
/** 彩带 */
@property(nonatomic, strong)UIImageView *colouredRibbon;

/** 二维码 */
@property(nonatomic, strong)UIImageView *qrCodeImageView;
@property(nonatomic, strong)UIButton *weixinButton;
@property(nonatomic, strong)UIButton *phoneButton;
@end

@implementation GenerateTXZViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"通行证";
    self.view.backgroundColor = kBgColor;
    [self.view addSubview:self.contentView];
    [self.contentView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.view);
        make.top.equalTo(self.view).offset(15);
        make.width.equalTo(kIphoneSize_Widith(300));
        make.height.equalTo(kIphoneSize_Height(400));
    }];
    [self.contentView addSubview:self.topImageView];
    [self.topImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.leading.trailing.equalTo(self.contentView);
        make.height.equalTo(kIphoneSize_Height(45));
        
    }];
    [self.contentView addSubview:self.nameLabel];
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.equalTo(20);
        make.trailing.equalTo(20);
        make.top.equalTo(self.topImageView.bottom);
        make.height.equalTo(50);
    }];
    [self.contentView addSubview:self.splitView];
    [self.splitView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.trailing.equalTo(self.nameLabel);
        make.top.equalTo(self.nameLabel.bottom);
        make.height.equalTo(1);
    }];
    [self.contentView addSubview:self.tipLabel];
    [self.tipLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.equalTo(self.nameLabel);
        make.top.equalTo(self.splitView.bottom).offset(10);
    }];
    [self.contentView addSubview:self.visitTimeLabel];
    [self.visitTimeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.equalTo(self.nameLabel);
        make.top.equalTo(self.tipLabel.bottom).offset(8);
    }];
    [self.contentView addSubview:self.colouredRibbon];
    [self.colouredRibbon mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.visitTimeLabel.bottom).offset(8);
        make.leading.trailing.equalTo(self.contentView);
        make.height.equalTo(15);
    
    }];
    
    [self.contentView addSubview:self.qrCodeImageView];
    
    UIView *tempView = [[UIView alloc]init];
    [self.contentView addSubview:tempView];
    [tempView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.bottom.trailing.equalTo(self.contentView);
        make.top.equalTo(self.colouredRibbon.bottom);
    }];
    [tempView addSubview:self.qrCodeImageView];
    
    [self.qrCodeImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.equalTo(kIphoneSize_Widith(150));
        make.height.equalTo(kIphoneSize_Height( 150));
        make.center.equalTo(tempView);

    }];
    
    [self.view addSubview:self.weixinButton];
    [self.weixinButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView.bottom).offset(20);
        make.leading.equalTo(self.contentView);
        make.trailing.equalTo(self.contentView.centerX).offset(-10);
        make.height.equalTo(kIphoneSize_Height(40));
    }];
    [self.view addSubview:self.phoneButton];
    [self.phoneButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.weixinButton);
        make.trailing.equalTo(self.contentView);
        make.leading.equalTo(self.contentView.centerX).offset(10);
        make.height.equalTo(self.weixinButton);
    }];
    
    
    

    
}

- (UIView *)contentView
{
    if (!_contentView) {
        _contentView = [[UIView alloc]init];
        _contentView.backgroundColor = [UIColor whiteColor];
    }
    return _contentView;
}
- (UIImageView *)topImageView
{
    if (!_topImageView) {
        _topImageView = [[UIImageView alloc]init];
        _topImageView.image = [UIImage imageNamed:@"passport_icon_top"];
    }
    return _topImageView;
}

- (UILabel *)nameLabel
{
    if (!_nameLabel) {
        _nameLabel = [[UILabel alloc]init];
        _nameLabel.text = @"尊敬的  李三女士";
         _nameLabel.font = [UIFont fontWithName:@"TrebuchetMS-Bold" size:18];
        
    
    }
    return _nameLabel;
}

- (UIView *)splitView
{
    if (!_splitView) {
        _splitView = [[UIView alloc]init];
        _splitView.backgroundColor = kSplitLineColor;
    }
    return _splitView;
}


- (UILabel *)tipLabel
{
    if (!_tipLabel) {
        _tipLabel = [[UILabel alloc]init];
        _tipLabel.text = @"请出示通行证给门岗";
        _tipLabel.textColor = RGBColor(153, 153, 153);
    }
    return _tipLabel;
}

- (UILabel *)visitTimeLabel
{
    if (!_visitTimeLabel) {
        _visitTimeLabel = [[UILabel alloc]init];
        _visitTimeLabel.text = @"到岗时间: 2016-6-23";
        _visitTimeLabel.textColor = RGBColor(153, 153, 153);
    }
    return _visitTimeLabel;
}
- (UIImageView *)colouredRibbon
{
    if (!_colouredRibbon) {
        _colouredRibbon = [[UIImageView alloc]init];
        _colouredRibbon.image = [UIImage imageNamed:@"passport_icon_background"];
    }
    return _colouredRibbon;
}

- (UIImageView *)qrCodeImageView
{
    if (!_qrCodeImageView) {
        _qrCodeImageView = [[UIImageView alloc]init];
        _qrCodeImageView.image = [UIImage imageNamed:@"passport_icon_qrcode"];
    }
    return _qrCodeImageView;
}
- (UIButton *)weixinButton
{
    if (!_weixinButton) {
        _weixinButton = [[UIButton alloc]init];
        [_weixinButton setTitle:@"微信好友" forState:UIControlStateNormal];
        _weixinButton.backgroundColor = kGlobalRedColor;
        _weixinButton.layer.cornerRadius = 10;
        _weixinButton.layer.masksToBounds = YES;
    }
    return _weixinButton;
}

- (UIButton *)phoneButton
{
    if (!_phoneButton) {
        _phoneButton = [[UIButton alloc]init];
        [_phoneButton setTitle:@"发送至手机" forState:UIControlStateNormal];
        _phoneButton.backgroundColor = [UIColor whiteColor];
        _phoneButton.layer.cornerRadius = 10;
        _phoneButton.layer.masksToBounds = YES;
        _phoneButton.layer.borderColor = kGlobalRedColor.CGColor;
        _phoneButton.layer.borderWidth = 1;
        [_phoneButton setTitleColor:kGlobalRedColor forState:UIControlStateNormal];
    }
    return _phoneButton;
}
@end
